package no.group.gowther.rest.vo.param;

import no.group.gowther.enums.FileType;
import no.group.gowther.exception.BusinessException;
import no.group.gowther.exception.ErrorMessage;
import no.group.gowther.service.dto.param.Page;

/**
 * @author ayatsuji
 * @date 2022-04-11 23:49
 * @since
 */
public class FileListQueryParam extends Page {
    private FileType type;
    private String dirPath;

    public void setType(String type) {
        try {
            this.type = FileType.valueOf(type);
        } catch (IllegalArgumentException e) {
            throw BusinessException.createException(
                    ErrorMessage.PARAM_ERROR.getErrorCode(),
                    String.format("不能查询类型为[%s]的文件", type));
        }
    }

    public FileType getType() {
        return type;
    }

    public void setDirPath(String dirPath) {
        this.dirPath = dirPath;
    }

    public void setType(FileType type) {
        this.type = type;
    }

    public String getDirPath() {
        return dirPath;
    }
}
